package com.wjc.train.business.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.wjc.train.business.req.StationQueryReq;
import com.wjc.train.business.resp.StationQueryResp;
import com.wjc.train.business.service.IStationService;
import com.wjc.train.common.resp.CommonResp;
import com.wjc.train.common.untils.PageUtil;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 车站表 前端控制器
 * </p>
 *
 * @author Guessed
 * @since 2023-08-14
 */
@RestController
@Validated
@RequestMapping("/station")
public class WebStationController {

    @Resource
    private IStationService stationService;


    @PostMapping("/query-list")
    public CommonResp save(@RequestBody StationQueryReq stationQueryReq){
        IPage<StationQueryResp> iPage =
        stationService.queryList(PageUtil.getPage(stationQueryReq.getQueryPage()), stationQueryReq);
        return CommonResp.success(new PageUtil(iPage));
    }

    @GetMapping("/query-all")
    public CommonResp queryAll(){
        return CommonResp.success(stationService.queryAll());
    }

}


